import { Controller, Get, UseGuards } from '@nestjs/common';
import { AppService } from './app.service';

import { AuthGuard } from '@nestjs/passport';
import { Roles } from './auth/roles.decorator';
import { RolesGuard } from './auth/roles.guard';


@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}

  @Get('public')
  publicRoute() {
    return 'This is public';
  }

  @Get('protected')
  @UseGuards(AuthGuard('jwt'))
  protectedRoute() {
    return 'This is protected';
  }

  @Get('admin')
  @UseGuards(AuthGuard('jwt'), RolesGuard)
  @Roles('admin')
  adminRoute() {
    return 'This is admin only';
  }
    @Get()
  getHello(): string {
    return this.appService.getHello();
  }
}
